<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class Animal {
            constructor (name, age) {
                this.name = name
                this.age = age
            }
            say () {
                console.log(`My name is ${this.name}, I am ${this.age} years old`)
            }
        }
        // extends关键字相当于实现原型链继承
        class Mouse extends Animal {
            constructor (name, age) {
                // super是ES6新增的方法，这个方法在继承子类的构造函数里调用
                // 相当于Animal.call(this, name, age)
                super(name, age)
            }
        }
        var jerry = new Mouse('Jerry', 80)
        jerry.say()

        console.log(jerry instanceof Mouse) // true
        console.log(jerry instanceof Animal) // true

    </script>
</body>
</html>